<button class="btn btn-info" type="button" onclick="back()">返回</button>
<ul class="nav nav-tabs">
    <li role="presentation"><a href="#" onclick="toIn()">盈余记录</a></li>
    <li role="presentation"  class="active"><a href="javascript:;">损耗记录</a></li>
</ul>
<table class="table" id="somainDiv">
    <thead>
    <tr>
        <th>序号</th>
        <th>产品编号</th>
        <th>产品名称</th>
        <th>原始数量</th>
        <th>实际数量</th>
        <th>盘点时间</th>
        <th>经手人</th>
        <th>损耗原因</th>
    </tr>
    </thead>
    <tbody id="tableBody"></tbody>
</table>

<script id="outCheckStockTemplate" type="text/html">
    {{each data value index}}
    <tr>
        <td>{{index+1}}</td>
        <td>{{value.productCode}}</td>
        <td name="productName"></td>
        <td>{{value.originNum}}</td>
        <td>{{value.realNum}}</td>
        <td>{{value.stockTime}}</td>
        <td>{{value.createUser}}</td>
        <td>{{value.description}}</td>
    </tr>
    {{/each}}
</script>

<script>
    $(function () {
        Ajax.post(
            "/selectOutCheckStock",
            {productCode:window.sessionStorage.getItem("storeProductCode")},
            function (result) {
                var div=document.getElementById("tableBody")
                var html=template('outCheckStockTemplate',{data:result.data})
                div.innerHTML=html
            }
        )
        Ajax.get(
            "/selectByProductCode",
            {productCode:window.sessionStorage.getItem("storeProductCode")},
            function (result) {
                document.getElementsByName("productName")
                for(var i=0;i<document.getElementsByName("productName").length;i++){
                    document.getElementsByName("productName")[i].innerHTML=result.data[0].name
                }
            }
        )

    })
    function toIn() {
        show("/store/inCheckStock.html")
    }
    function back() {
        show("/store/checkStock.html")
    }
</script>
